
from autoTest_ecshop.utils.log_util import logger

def assert_util(expectRes,compare,actualRes):
    try:
        logger.info(f"断言：{expectRes} {compare} {actualRes}")
        if compare =="in":
            assert expectRes in actualRes
        elif compare== "==":
            assert expectRes == actualRes
        elif compare== ">=":
            assert expectRes >= actualRes
        elif compare== ">":
            assert expectRes > actualRes
        elif compare== "<=":
            assert expectRes <= actualRes
        elif compare== "<":
            assert expectRes < actualRes
        elif compare== "!=" or compare =="<>":
            assert expectRes != actualRes
        else:
            logger.error("您输入的比对方式有误")
            raise
        logger.info(f"断言成功\n")
    except Exception as e:
        logger.error("断言失败，错误信息是：\n{e}\n")
        raise